package demo;

import java.util.Random;

public class test1 {
    //需求：打乱字符串顺序
    public static void main(String[] args) {
        //1.创建一个字符串
        String str="abcdef123";
        //2.转换成字符数组
        char[] arr=str.toCharArray();
        //3.模仿数组乱序
        Random r=new Random();
        for (int i = 0; i < arr.length; i++) {
            int pos=r.nextInt(arr.length);
            char tmp=arr[pos];
            arr[pos]=arr[i];
            arr[i]=tmp;
        }
        //4.转换会字符并输出
        String sttr=new String(arr);
        System.out.println(sttr);
    }

}
